/**
 emma_project
 Copyright (C) 2015  Rodrigo Garcia

 This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
/*
This header is meant to contain function definitions to log data
into FILES inside the SD card.
 
- See: Docu/datalog_format (Log File format)
*/

#ifndef DATA_LOGGER_H

#define DATA_LOGGER_H

#include <stdio.h>
#include "SD_generic.h"
#include "sensors.h"

#include "ProgMemLink.h"

struct LogFile
{
  unsigned char FileName[11]; 
  //unsiged char Date_info // to write in File MetaData
  char time[9];
};

unsigned char change_table_header;

// Set the DataLog Metadata and tells wether to append or overwrite the string
char Set_DatalogMetaData(struct LogFile *logfile, unsigned char *file_name, char appendName);

// Set the DataLog time.
char Set_DatalogTime(struct LogFile *logfile, char *time, char appendTime);

///Log into file
// See Docu/datalog_format
void LogIntoFile(struct LogFile *logfile);

/// Some utilities to log data

// If the sensor_data_read is valid, then it is appended in the
// new_content_buffer (to be saved in a file later)
// , otherwise a blank space is appended instead.
void AppendAndCheckValidDataFromSensor(float sensor_data_read, const char *filename);

#endif
